﻿@using System.Web.Caching;
@{
	string version = Request.QueryString["version"];
	WebPageHttpHandler.DisableWebPagesResponseHeader = true;

	if (!Request.IsLocal)
	{
		Response.Cache.SetExpires(DateTime.Now.AddDays(30));
		Response.Cache.SetValidUntilExpires(true);
		Response.Cache.SetCacheability(HttpCacheability.Public);
		Response.Cache.VaryByParams["version"] = true;
		Response.AddFileDependency(Server.MapPath("~/index.cshtml"));
		Response.AddFileDependency(Server.MapPath("~/app_data/" + version + ".xml"));
		Response.AddFileDependency(Server.MapPath("~/css/site.min.css"));
		Response.AddFileDependency(Server.MapPath("~/site.appcache"));
		Response.Cache.SetLastModifiedFromFileDependencies();
	}
}
<!DOCTYPE html>
<html manifest="@Fingerprint("/site.appcache")" itemscope itemtype="http://schema.org/WebPage">
<head>
	<meta charset="utf-8" />
	<title>Visual Studio @version keyboard shortcuts - complete list</title>
	<link rel="icon" href="@Fingerprint("/favicon.ico")" type="image/x-icon" />
	<meta name="description" content="A complete list of all keyboard shortcuts in Visual Studio @version" />
	<meta name="keywords" content="shortcut, shortcuts, keybinding, key binding, vs, visual studio @version" />
	<style>@Html.Raw(File.ReadAllText(Server.MapPath("~/css/site.min.css")))</style>
</head>
<body>

	<header role="banner">
		<h1>Visual Studio @version keyboard shortcuts</h1>
		<h2>The complete list</h2>
		<nav>
			<ul>
				<li><a href="/2012/">2012</a></li>
				<li><a href="/2013/">2013</a></li>
				<li><a href="/2015/">2015</a></li>
			</ul>
		</nav>
	</header>

	<section role="main">
		@RenderPage("commands.cshtml", version)
	</section>

	<aside>
		<a href="https://github.com/madskristensen/shortcutExporter">Fork me on GitHub</a>
	</aside>

	<footer role="contentinfo">
		<p>@Commands.ShortcutCount shortcuts in total</p>
		<p>Get the <a href="http://visualstudiogallery.msdn.microsoft.com/6ce3b73c-2284-4b95-b61d-6de74aa8dfe6">Visual Studio extension</a></p>
		<p>
			Copyright &copy; 2013 - @DateTime.Now.Year
			<a href="http://madskristensen.net" rel="me author publisher">Mads Kristensen</a>
		</p>
	</footer>

	<script>
		(function (i, s, o, g, r, a, m) {
			i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
				(i[r].q = i[r].q || []).push(arguments)
			}, i[r].l = 1 * new Date(); a = s.createElement(o),
            m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
		})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

		ga('create', 'UA-322803-2', 'visualstudioshortcuts.com');
		ga('send', 'pageview');
	</script>
</body>
</html>

@functions{
	private string Fingerprint(string rootRelativePath, string cdnPath = "")
	{
		if (!string.IsNullOrEmpty(cdnPath) && !Context.IsDebuggingEnabled)
		{
			return cdnPath;
		}

		string relative = VirtualPathUtility.ToAbsolute("~" + rootRelativePath);
		string absolute = Server.MapPath(relative);

		if (!File.Exists(absolute))
		{
			throw new FileNotFoundException("File not found", absolute);
		}

		DateTime date = File.GetLastWriteTime(absolute);
		int index = relative.LastIndexOf('/');

		return relative.Insert(index, "/v-" + date.Ticks);
	}
}
